from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver = webdriver.Chrome()
driver.get("https://www.baidu.com")
# id定位
# driver.find_element(By.ID, "kw").send_keys("python")
# name定位
# driver.find_element(By.NAME, "wd").send_keys("python")

# 定位一组元素
# eles = driver.find_elements(By.XPATH, "//input")
# print(type(eles))
# for i in eles:
#     print(i)

# # 元素内输入数据
# ele = driver.find_element(By.XPATH, "//input[@id='kw']")  # 先定位元素
# ele.send_keys("python")  # 对元素进行输入
# time.sleep(3)
# # 元素点击
# ele = driver.find_element(By.XPATH, "//input[@id='su']")  # 先定位元素
# # ele.click()  # 对元素进行点击
# ele.submit()
# time.sleep(3)
# # 清空元素内内容
# ele = driver.find_element(By.XPATH, "//input[@id='kw']")  # 先定位元素
# ele.clear()
# time.sleep(2)
# ele.send_keys("坚果")

ele = driver.find_element(By.XPATH, "//span[@id='s-usersetting-top']")
# 获取元素内文本信息
print(ele.text)
# 获取属性值
print(ele.get_attribute("class"))
# 获取元素尺寸
print(ele.size)
# 判断元素是否可见
print(ele.is_displayed())

time.sleep(5)
driver.quit()